package com.example.lib_storage.database.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import com.example.lib_storage.database.entity.HistoryEntity

/**
 * @author yaotianxue
 * @description
 * @date 2024/10/23
 */
@Dao
interface HistoryDao {
    @Query("select * from b_history order by id desc limit 5")
    fun getAll():List<HistoryEntity>

    @Query("select * from b_history order by id desc limit (:page * :pagesize) ,:pagesize")
    fun getAllByPage(page: Int,pagesize:Int):List<HistoryEntity>

    @Query("select * from b_history where content like  '%'+:keywords+'%'  order by id desc ")
    fun getAllByKeyWords(keywords:String):List<HistoryEntity>

    @Insert
    fun insertAll(vararg  entity: HistoryEntity)

    @Delete
    fun delete(entity: HistoryEntity)

    @Query("delete from b_history")
    fun deleteAll()
}